<template>
  <div class="banner_swiper-box">
    <div class="banner_swiper">
      <el-carousel trigger="click" height="480px" :interval="10000">
        <el-carousel-item v-for="(item, index) of bannerList" :key="index">
          <div class="banner-box" :style="{backgroundImage: 'url(' + item.coverUrl + ')'}" @click="openNew(item)">
            <div class="title-box">
              <div class="title">{{item.name}}</div>
            </div>
          </div>
        </el-carousel-item>
      </el-carousel>
    </div>
  </div>
</template>

<script>
import { advertsList } from '@/api/api';

export default {
  data() {
    return {
      bannerList: []
    }
  },
  mounted() {
    this.getList();
  },
  methods: {
    async getList() {
      const params = {
        type: 'LB_BANNER',
        pageType: 'HD_PAGE',
        status: 1
      };
      const res = await advertsList(params);
      this.bannerList = res.list || [];
    },
    openNew (item) {
      window.open(item.linkUrl)
    }
  }
}
</script>

<style lang="scss" scoped>
.banner_swiper-box {
  padding-bottom: 36px;
  overflow: hidden;
  .banner_swiper {
    width: 1180px;
    // height: 480px;
    margin: 0 auto;
    overflow: hidden;
    .banner-box {
      height: 480px;
      background-size: cover;
      position: relative;
      cursor: pointer;
      .title-box {
        width: 100%;
        position: absolute;
        bottom: 0;
        left: 0;
        padding: 24px;
        box-sizing: border-box;
        background: linear-gradient(-180deg,transparent,rgba(0,0,0,.65) 97%);
        .type {
          width: 24px;
          height: 20px;
          font-size: 12px;
          font-family: PingFangSC-Semibold, PingFang SC;
          font-weight: 600;
          color: #FFFFFF;
          line-height: 20px;
          margin-bottom: 5px;
          background: #D42A31;
          padding: 0 6px;
        }
        .title {
          height: 36px;
          font-size: 24px;
          font-family: PingFangSC-Semibold, PingFang SC;
          font-weight: 600;
          color: #FFFFFF;
          line-height: 36px;
          overflow:hidden; 
          text-overflow:ellipsis;
          white-space: nowrap;
        }
      }
    }
  }
  /deep/ .el-carousel__indicators {
    position: relative;
    text-align: center;
    .el-carousel__indicator--horizontal {
      padding: 16px 4px;
    }
  }
  /deep/ .el-carousel__button {
    width: 60px;
    height: 8px;
    background-color: #D8D8D8;
  }
  /deep/ .is-active .el-carousel__button {
    background-color: #D42A31;
  }
}
</style>